// pages/mytrips/mytrips.ts
// import { IAppOption } from "../../appoption"
//import { ProfileService } from "../../service/profile"
//import { rental } from "../../service/proto_gen/rental/rental_pb"
//import { TripService } from "../../service/trip"
// import { formatDuration, formatFee } from "../../utils/format"
import { TripService } from "../../service/trip"
import { routing } from "../../utils/routing"

interface Trip {
    id: string
    shortId: string
    start: string
    end: string
    duration: string
    fee: string
    distance: string
    status: string
    inProgress: boolean
}

interface MainItem {
    id: string
    navId: string
    navScrollId: string
    data: Trip
}

interface NavItem {
    id: string
    mainId: string
    label: string
}

interface MainItemQueryResult {
    id: string
    top: number
    dataset: {
        navId: string
        navScrollId: string
    }
}

// const tripStatusMap = new Map([
//     [rental.v1.TripStatus.IN_PROGRESS, '进行中'],
//     [rental.v1.TripStatus.FINISHED, '已完成'],
// ])

// const licStatusMap = new Map([
//     [rental.v1.IdentityStatus.UNSUBMITTED, '未认证'],
//     [rental.v1.IdentityStatus.PENDING, '未认证'],
//     [rental.v1.IdentityStatus.VERIFIED, '已认证'],
// ])

Page({
  scrollStates: {
    mainItems: [] as MainItemQueryResult[],
},

layoutResolver: undefined as (()=>void)|undefined,

  data: {
    promotionItems: [
        {
            img: 'https://img.mukewang.com/5f7301d80001fdee18720764.jpg',
            promotionID: 1,
        },            
        {
            img: 'https://img.mukewang.com/5f6805710001326c18720764.jpg',
            promotionID: 2,
        },
        {
            img: 'https://img.mukewang.com/5f6173b400013d4718720764.jpg',
            promotionID: 3,
        },
        {
            img: 'https://img.mukewang.com/5f7141ad0001b36418720764.jpg',
            promotionID: 4,
        },
    ],
    // licStatus: licStatusMap.get(rental.v1.IdentityStatus.UNSUBMITTED),
    avatarURL: '',
    tripsHeight: 0,
    navCount: 0,
    mainItems: [] as MainItem[],
    mainScroll: '',
    navItems: [] as NavItem[],
    navSel: '',
    navScroll: '',
  },
  async onLoad(){
    const res = await TripService.getTrips()
    console.log(res);
  },
  onPromotionItemTap(e: any) {
    const promotionID:number = e.currentTarget.dataset.promotionId
    if (promotionID) {
        console.log('claiming promotion', promotionID)
    }
  }, 
  onRegisterTap() {
    wx.navigateTo({
        url: routing.register(),
    })
}, 
})